package oopdemo.test;

public class GirlFriend {
    private String name;
    private int age;
    private String gender;
    // 针对于每一个私有化的成员变量，都要提供get和set方法
    // set方法：给成员变量赋值
    // get方法 ： 对外提供成员变量的值
    public void setName(String name){
        this.name = name;
    }

    public String getName(){
        return this.name;
    }
    public void setAge(int a ){
        if (a >= 18 && a <=50){
            this.age = a;
        }else{
            System.out.println("非法参数");
        }
    }
    public int getAge(){
        return this.age;
    }
    public void setGender(String gender){
        this.gender = gender;
    }
    public String getGender(){
        return this.gender;
    }
    public void sleep(){
        System.out.println("女朋友在睡觉");
    }

    public void eat() {
        System.out.println("女朋友在吃饭");
    }
}
